package tree;

import javax.swing.*;

import java.awt.Color;
import java.awt.Image;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Deftree implements ActionListener {
	
	static int deftreepoints = 0;
	int totalpoints = 40;
	boolean recentreset = false;
	
	public static int getdefpoints() {
		return deftreepoints;
	}
	
	Skill onemastery = Defskills.onehmastery();
	Skill bastion = Defskills.bastion();
	Skill chaotic = Defskills.chaotic();
	Skill comeback = Defskills.comeback();
	Skill defmastery = Defskills.dmastery();
	Skill dshout = Defskills.dshout();
	Skill eshout = Defskills.eshout();
	Skill evastrike = Defskills.evastrike();
	Skill fshout = Defskills.fshout();
	Skill gale = Defskills.gale();
	Skill massive = Defskills.massive();
	Skill piercing = Defskills.piercing();
	Skill rapid = Defskills.rapid();
	Skill resiliance = Defskills.resiliance();
	Skill retribution = Defskills.retri();
	Skill ruin = Defskills.ruin();
	Skill rush = Defskills.rush();
	Skill shield = Defskills.shield();
	Skill slam = Defskills.slam();
	Skill steel = Defskills.steel();
	Skill stone = Defskills.stone();
	Skill stunning = Defskills.stunning();
	Skill thorn = Defskills.thorn();
	Skill threaten = Defskills.threaten();
	Skill vigilance = Defskills.vigilance();
	
	static JFrame frame;
	JPanel masterypanel, skills, row1,row2,row3,row4,row5,row6,row7, masrow1,masrow2,masrow3,
	masrow4,masrow5,masrow6,masrow7;
	
	JButton resetall, reset, def, zerk, cleric, sorc, sin, sor,stunn, rus, thor, onem, slamm, comeb, pierce,rapi, 
		fshou, defma, chaot, massiv, basti, ston, shiel, stee, eshou, resil, gal, evas, vigil, dshou, threate, retr;
	
	JLabel title1, title2, info, row12arr, rui,stun, rushh, tho, one, row2arr, sla, come, pierc, row34arr, row3arr,
		rap, fsho, defm, chao, massi, bast, sto, shie, ste, esho, resi, ga, eva, vigi, dsho, threat, ret, counter, counte,
		chain, chai, cross, cros, plate, plat, phy1, phy11, phy2, phy22, phy3, phy33, exe1, exe11, exe2, exe22;
	
	static JPanel allpanels;
	
	
	
	
	public JPanel createContentPane (){
		
		totalpoints = 40;
		deftreepoints = 0;
		ImageIcon img;
		Image test;
		Image newimg;
		
		ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);

        allpanels = new JPanel();
        allpanels.setLayout(null);
		
        title1 = new JLabel("Actives/Passives");
        title1.setLocation(5, 0);
        title1.setSize(430,20);
        title1.setHorizontalAlignment(0);
        title1.setOpaque(true);
        title1.setBackground(Color.gray);
        allpanels.add(title1);
        
        title2 = new JLabel("Masteries");
        title2.setLocation(435, 0);
        title2.setSize(110,20);
        title2.setHorizontalAlignment(0);
        title2.setOpaque(true);
        title2.setBackground(Color.gray);
        allpanels.add(title2);
        
        skills = new JPanel();
        skills.setLayout(null);
        skills.setSize(430, 430);
        skills.setLocation(5,20);
        allpanels.add(skills);
        
        masterypanel = new JPanel();
        masterypanel.setLayout(null);
        masterypanel.setSize(110, 430);
        masterypanel.setLocation(435,20);
        allpanels.add(masterypanel);
        
      //masteries
        masrow1 = new JPanel();
        masrow1.setLayout(null);
        masrow1.setLocation(0, 0);
        masrow1.setSize(110, 60);
        masrow1.setBackground(Color.lightGray);
        masrow1.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow1);
        
      //Counterattack
        img = new ImageIcon(getClass().getResource("/defender/counterattack.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        counter = new JLabel();
        counter.setSize(40,40);
        counter.setToolTipText("<html>Counterattack<br>Increases physical and magical damage by 10% for 10 seconds and allows the<br>" +
        						"use of additional skills. Triggered by a full block or a hit with rush or evasive strike<br>" +
        						"Requires 5+ points in defender</html>");
        counter.setLocation(10, 10);
        counter.setOpaque(true);
        counter.setBackground(new Color(128,128,128,175));
        masrow1.add(counter);
        
        counte = new JLabel((Icon) img);
        counte.setSize(40,40);
        counte.setLocation(10, 10);
        masrow1.add(counte);
        
      //Chain mastery
        img = new ImageIcon(getClass().getResource("/defender/chainmastery.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        chain = new JLabel();
        chain.setSize(40,40);
        chain.setToolTipText("<html>Chain Armor Mastery<br>Allows you to equip chain armor.<br>" +
        						"Requires 5+ points in defender</html>");
        chain.setLocation(60, 10);
        chain.setOpaque(true);
        chain.setBackground(new Color(128,128,128,175));
        masrow1.add(chain);
        
        chai = new JLabel((Icon) img);
        chai.setSize(40,40);
        chai.setLocation(60, 10);
        masrow1.add(chai);
        
        //mastrow2
        masrow2 = new JPanel();
        masrow2.setLayout(null);
        masrow2.setLocation(0, 60);
        masrow2.setSize(110, 60);
        masrow2.setBackground(Color.lightGray);
        masrow2.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow2);
        
      //Style mastery
        img = new ImageIcon(getClass().getResource("/defender/stylemastery.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        cross = new JLabel();
        cross.setSize(40,40);
        cross.setToolTipText("<html>Style Mastery: Defender<br>Allows you learn skills of other styles.<br>" +
        						"Requires 10+ points in defender</html>");
        cross.setLocation(35, 10);
        cross.setOpaque(true);
        cross.setBackground(new Color(128,128,128,175));
        masrow2.add(cross);
        
        cros = new JLabel((Icon) img);
        cros.setSize(40,40);
        cros.setLocation(35, 10);
        masrow2.add(cros);
        
      //mastrow3
        masrow3 = new JPanel();
        masrow3.setLayout(null);
        masrow3.setLocation(0, 120);
        masrow3.setSize(110, 60);
        masrow3.setBackground(Color.lightGray);
        masrow3.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow3);
        
      //Plate mastery
        img = new ImageIcon(getClass().getResource("/defender/platemastery.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        plate = new JLabel();
        plate.setSize(40,40);
        plate.setToolTipText("<html>Plate Armor Mastery<br>Allows you to equip plate armor.<br>" +
        						"Requires 15+ points in defender</html>");
        plate.setLocation(10, 10);
        plate.setOpaque(true);
        plate.setBackground(new Color(128,128,128,175));
        masrow3.add(plate);
        
        plat = new JLabel((Icon) img);
        plat.setSize(40,40);
        plat.setLocation(10, 10);
        masrow3.add(plat);
        
      //Physical Training
        img = new ImageIcon(getClass().getResource("/defender/phytraining.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        phy1 = new JLabel();
        phy1.setSize(40,40);
        phy1.setToolTipText("<html>Physical Training<br>Incoming damage is reduced by 2%.<br>" +
        						"Requires 15+ points in defender</html>");
        phy1.setLocation(60, 10);
        phy1.setOpaque(true);
        phy1.setBackground(new Color(128,128,128,175));
        masrow3.add(phy1);
        
        phy11 = new JLabel((Icon) img);
        phy11.setSize(40,40);
        phy11.setLocation(60, 10);
        masrow3.add(phy11);
        
      //mastrow4
        masrow4 = new JPanel();
        masrow4.setLayout(null);
        masrow4.setLocation(0, 180);
        masrow4.setSize(110, 60);
        masrow4.setBackground(Color.lightGray);
        masrow4.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow4);
        
      //Exetended Counterattack
        img = new ImageIcon(getClass().getResource("/defender/extendcounter.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        exe1 = new JLabel();
        exe1.setSize(40,40);
        exe1.setToolTipText("<html>Exetended Counterattack<br>Increases the duration of counterattack by 2 seconds.<br>" +
        						"Requires 20+ points in defender</html>");
        exe1.setLocation(35, 10);
        exe1.setOpaque(true);
        exe1.setBackground(new Color(128,128,128,175));
        masrow4.add(exe1);
        
        exe11 = new JLabel((Icon) img);
        exe11.setSize(40,40);
        exe11.setLocation(35, 10);
        masrow4.add(exe11);
        
      //mastrow5
        masrow5 = new JPanel();
        masrow5.setLayout(null);
        masrow5.setLocation(0, 240);
        masrow5.setSize(110, 60);
        masrow5.setBackground(Color.lightGray);
        masrow5.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow5);
        
      //Physical Training
        img = new ImageIcon(getClass().getResource("/defender/phytraining.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        phy2 = new JLabel();
        phy2.setSize(40,40);
        phy2.setToolTipText("<html>Physical Training 2<br>Incoming damage is reduced by 4%.<br>" +
        						"Requires 25+ points in defender</html>");
        phy2.setLocation(35, 10);
        phy2.setOpaque(true);
        phy2.setBackground(new Color(128,128,128,175));
        masrow5.add(phy2);
        
        phy22 = new JLabel((Icon) img);
        phy22.setSize(40,40);
        phy22.setLocation(35, 10);
        masrow5.add(phy22);
        
      //mastrow6
        masrow6 = new JPanel();
        masrow6.setLayout(null);
        masrow6.setLocation(0, 300);
        masrow6.setSize(110, 60);
        masrow6.setBackground(Color.lightGray);
        masrow6.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow6);
        
      //Exetended Counterattack
        img = new ImageIcon(getClass().getResource("/defender/extendcounter.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        exe2 = new JLabel();
        exe2.setSize(40,40);
        exe2.setToolTipText("<html>Exetended Counterattack 2<br>Increases the duration of counterattack by 4 seconds.<br>" +
        						"Requires 30+ points in defender</html>");
        exe2.setLocation(35, 10);
        exe2.setOpaque(true);
        exe2.setBackground(new Color(128,128,128,175));
        masrow6.add(exe2);
        
        exe22 = new JLabel((Icon) img);
        exe22.setSize(40,40);
        exe22.setLocation(35, 10);
        masrow6.add(exe22);
        
      //mastrow7
        masrow7 = new JPanel();
        masrow7.setLayout(null);
        masrow7.setLocation(0, 360);
        masrow7.setSize(110, 60);
        masrow7.setBackground(Color.lightGray);
        masrow7.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.BLACK));
        masterypanel.add(masrow7);
        
      //Physical Training
        img = new ImageIcon(getClass().getResource("/defender/phytraining.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        phy3 = new JLabel();
        phy3.setSize(40,40);
        phy3.setToolTipText("<html>Physical Training 3<br>Incoming damage is reduced by 6%.<br>" +
        						"Requires 35+ points in defender</html>");
        phy3.setLocation(35, 10);
        phy3.setOpaque(true);
        phy3.setBackground(new Color(128,128,128,175));
        masrow7.add(phy3);
        
        phy33 = new JLabel((Icon) img);
        phy33.setSize(40,40);
        phy33.setLocation(35, 10);
        masrow7.add(phy33);
        
        
        
        def = new JButton();
        def.setText("Defender(0)");
        def.setSize(110,20);
        def.setLocation(5, 450);
        def.setHorizontalAlignment( SwingConstants.LEFT );
        def.addActionListener(this);
        allpanels.add(def);
        
        zerk = new JButton();
        zerk.setText("Berserker(0)");
        zerk.setSize(120,20);
        zerk.setLocation(115, 450);
        zerk.setHorizontalAlignment( SwingConstants.LEFT );
        zerk.addActionListener(this);
        allpanels.add(zerk);
        
        cleric = new JButton();
        cleric.setText("Cleric(0)");
        cleric.setSize(90,20);
        cleric.setLocation(235, 450);
        cleric.setHorizontalAlignment( SwingConstants.CENTER );
        cleric.addActionListener(this);
        allpanels.add(cleric);
        
        sorc = new JButton();
        sorc.setText("Sorcerer(0)");
        sorc.setSize(110,20);
        sorc.setLocation(325, 450);
        sorc.setHorizontalAlignment( SwingConstants.LEFT );
        sorc.addActionListener(this);
        allpanels.add(sorc);
        
        sin = new JButton();
        sin.setText("Assassin(" + Sintree.getsinpoints() + ")");
        sin.setSize(110,20);
        sin.setLocation(435, 450);
        sin.setHorizontalAlignment( SwingConstants.LEFT );
        sin.addActionListener(this);
        allpanels.add(sin);
        
        
        info = new JLabel();
        info.setText("<html>Points Used: " + deftreepoints + "<br>Points Left: " + (totalpoints-(deftreepoints)) + "</html>");
        info.setSize(550,40);
        info.setHorizontalAlignment( SwingConstants.CENTER );
        info.setLocation(0, 470);
        allpanels.add(info);
        
        reset = new JButton();
        reset.setText("Reset Tree");
        reset.setSize(100, 20);
        reset.setLocation(225, 510);
        reset.setHorizontalAlignment( SwingConstants.CENTER );
        reset.addActionListener(this);
        allpanels.add(reset);
        
        resetall = new JButton("Reset All");
        resetall.setSize(100, 20);
        resetall.setLocation(225, 530);
        resetall.setHorizontalAlignment( SwingConstants.CENTER );
        resetall.addActionListener(this);
        allpanels.add(resetall);
        
        
        //row1
        row1 = new JPanel();
        row1.setLayout(null);
        row1.setLocation(0, 0);
        row1.setSize(430, 60);
        row1.setBackground(Color.lightGray);
        row1.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.BLACK));
        skills.add(row1);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 20,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row12arr = new JLabel((Icon) img);
        row12arr.setSize(20,20);
        row12arr.setLocation(160, 50);
        skills.add(row12arr,0);
        
      //Strike of Ruin
        img = new ImageIcon(getClass().getResource("/defender/ruin.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        sor = new JButton((Icon) img);
        sor.setToolTipText("<html>" + ruin.popup() + "</html>");
        sor.setSize(40, 40);
        sor.setLocation(10, 10);
        sor.addActionListener(this);
        row1.add(sor);
        
        rui = new JLabel();
        rui.setText(ruin.getlv() + "/" + ruin.getmax());
        rui.setSize(20,20);
        rui.setLocation(50, 30);
        row1.add(rui);
        
      //Stunning Smash
        img = new ImageIcon(getClass().getResource("/defender/stunning.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        stunn = new JButton((Icon) img);
        stunn.setToolTipText("<html>" + stunning.popup() + "</html>");
        stunn.setSize(40, 40);
        stunn.setLocation(80, 10);
        stunn.addActionListener(this);
        row1.add(stunn);
        
        stun = new JLabel();
        stun.setText(stunning.getlv() + "/" + stunning.getmax());
        stun.setSize(20,20);
        stun.setLocation(120, 30);
        row1.add(stun);
        
      //Rush
        img = new ImageIcon(getClass().getResource("/defender/rush.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        rus = new JButton((Icon) img);
        rus.setToolTipText("<html>" + rush.popup() + "</html>");
        rus.setSize(40, 40);
        rus.setLocation(150, 10);
        rus.addActionListener(this);
        row1.add(rus);
        
        rushh = new JLabel();
        rushh.setText(rush.getlv() + "/" + rush.getmax());
        rushh.setSize(20,20);
        rushh.setLocation(190, 30);
        row1.add(rushh);
        
      //Thorn
        img = new ImageIcon(getClass().getResource("/defender/thorn.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        thor = new JButton((Icon) img);
        thor.setToolTipText("<html>" + thorn.popup() + "</html>");
        thor.setSize(40, 40);
        thor.setLocation(290, 10);
        thor.addActionListener(this);
        row1.add(thor);
        
        tho = new JLabel();
        tho.setText(thorn.getlv() + "/" + thorn.getmax());
        tho.setSize(20,20);
        tho.setLocation(330, 30);
        row1.add(tho);
        
      //Onehmastery
        img = new ImageIcon(getClass().getResource("/defender/1hmastery.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        onem = new JButton((Icon) img);
        onem.setToolTipText("<html>" + onemastery.popup() + "</html>");
        onem.setSize(40, 40);
        onem.setLocation(360, 10);
        onem.addActionListener(this);
        row1.add(onem);
        
        one = new JLabel();
        one.setText(onemastery.getlv() + "/" + onemastery.getmax());
        one.setSize(20,20);
        one.setLocation(400, 30);
        row1.add(one);
        
        //row2
        row2 = new JPanel();
        row2.setLayout(null);
        row2.setLocation(0, 60);
        row2.setSize(430, 60);
        row2.setBackground(Color.lightGray);
        row2.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
        skills.add(row2);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 58,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row2arr = new JLabel((Icon) img);
        row2arr.setSize(20,58);
        row2arr.setLocation(90, 1);
        row2.add(row2arr);
        
      //Slam
        img = new ImageIcon(getClass().getResource("/defender/slam.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        slamm = new JButton((Icon) img);
        slamm.setToolTipText("<html>" + slam.popup() + "</html>");
        slamm.setSize(40, 40);
        slamm.setLocation(150, 10);
        slamm.addActionListener(this);
        row2.add(slamm);
        
        sla = new JLabel();
        sla.setText(slam.getlv() + "/" + slam.getmax());
        sla.setSize(20,20);
        sla.setLocation(190, 30);
        row2.add(sla);
        
      //Comeback
        img = new ImageIcon(getClass().getResource("/defender/comeback.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        comeb = new JButton((Icon) img);
        comeb.setToolTipText("<html>" + comeback.popup() + "</html>");
        comeb.setSize(40, 40);
        comeb.setLocation(220, 10);
        comeb.addActionListener(this);
        row2.add(comeb);
        
        come = new JLabel();
        come.setText(comeback.getlv() + "/" + comeback.getmax());
        come.setSize(20,20);
        come.setLocation(260, 30);
        row2.add(come);
        
      //row3
        row3 = new JPanel();
        row3.setLayout(null);
        row3.setLocation(0, 120);
        row3.setSize(430, 60);
        row3.setBackground(Color.lightGray);
        row3.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
        skills.add(row3);
        
      //Piercing Strike
        img = new ImageIcon(getClass().getResource("/defender/piercing.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        pierce = new JButton((Icon) img);
        pierce.setToolTipText("<html>" + piercing.popup() + "</html>");
        pierce.setSize(40, 40);
        pierce.setLocation(10, 10);
        pierce.addActionListener(this);
        row3.add(pierce);
        
        pierc = new JLabel();
        pierc.setText(piercing.getlv() + "/" + piercing.getmax());
        pierc.setSize(20,20);
        pierc.setLocation(50, 30);
        row3.add(pierc);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 20,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row34arr = new JLabel((Icon) img);
        row34arr.setSize(20,20);
        row34arr.setLocation(20, 170);
        skills.add(row34arr,0);
        
      //Rapid Assault
        img = new ImageIcon(getClass().getResource("/defender/rapid.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        rapi = new JButton((Icon) img);
        rapi.setToolTipText("<html>" + rapid.popup() + "</html>");
        rapi.setSize(40, 40);
        rapi.setLocation(80, 10);
        rapi.addActionListener(this);
        row3.add(rapi);
        
        rap = new JLabel();
        rap.setText(rapid.getlv() + "/" + rapid.getmax());
        rap.setSize(20,20);
        rap.setLocation(120, 30);
        row3.add(rap);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 58,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row3arr = new JLabel((Icon) img);
        row3arr.setSize(20,58);
        row3arr.setLocation(160, 1);
        row3.add(row3arr);
        
      //Fortify Shout
        img = new ImageIcon(getClass().getResource("/defender/fortify.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        fshou = new JButton((Icon) img);
        fshou.setToolTipText("<html>" + fshout.popup() + "</html>");
        fshou.setSize(40, 40);
        fshou.setLocation(290, 10);
        fshou.addActionListener(this);
        row3.add(fshou);
        
        fsho = new JLabel();
        fsho.setText(fshout.getlv() + "/" + fshout.getmax());
        fsho.setSize(20,20);
        fsho.setLocation(330, 30);
        row3.add(fsho);
        
      //Defense Mastery
        img = new ImageIcon(getClass().getResource("/defender/defensemastery.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        defma = new JButton((Icon) img);
        defma.setToolTipText("<html>" + defmastery.popup() + "</html>");
        defma.setSize(40, 40);
        defma.setLocation(360, 10);
        defma.addActionListener(this);
        row3.add(defma);
        
        defm = new JLabel();
        defm.setText(defmastery.getlv() + "/" + defmastery.getmax());
        defm.setSize(20,20);
        defm.setLocation(400, 30);
        row3.add(defm);
        
      //row4
        row4 = new JPanel();
        row4.setLayout(null);
        row4.setLocation(0, 180);
        row4.setSize(430, 60);
        row4.setBackground(Color.lightGray);
        row4.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
        skills.add(row4);
        
      //Chaotic Strike
        img = new ImageIcon(getClass().getResource("/defender/chaotic.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        chaot = new JButton((Icon) img);
        chaot.setToolTipText("<html>" + chaotic.popup() + "</html>");
        chaot.setSize(40, 40);
        chaot.setLocation(10, 10);
        chaot.addActionListener(this);
        row4.add(chaot);
        
        chao = new JLabel();
        chao.setText(chaotic.getlv() + "/" + chaotic.getmax());
        chao.setSize(20,20);
        chao.setLocation(50, 30);
        row4.add(chao);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 58,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row2arr = new JLabel((Icon) img);
        row2arr.setSize(20,58);
        row2arr.setLocation(90, 1);
        row4.add(row2arr);
        
      //Massive Strike
        img = new ImageIcon(getClass().getResource("/defender/massive.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        massiv = new JButton((Icon) img);
        massiv.setToolTipText("<html>" + massive.popup() + "</html>");
        massiv.setSize(40, 40);
        massiv.setLocation(150, 10);
        massiv.addActionListener(this);
        row4.add(massiv);
        
        massi = new JLabel();
        massi.setText(massive.getlv() + "/" + massive.getmax());
        massi.setSize(20,20);
        massi.setLocation(190, 30);
        row4.add(massi);
        
      //Bastion
        img = new ImageIcon(getClass().getResource("/defender/bastion.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        basti = new JButton((Icon) img);
        basti.setToolTipText("<html>" + bastion.popup() + "</html>");
        basti.setSize(40, 40);
        basti.setLocation(220, 10);
        basti.addActionListener(this);
        row4.add(basti);
        
        bast = new JLabel();
        bast.setText(bastion.getlv() + "/" + bastion.getmax());
        bast.setSize(20,20);
        bast.setLocation(260, 30);
        row4.add(bast);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 58,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row3arr = new JLabel((Icon) img);
        row3arr.setSize(20,58);
        row3arr.setLocation(300, 1);
        row4.add(row3arr);
        
      //Stone armor
        img = new ImageIcon(getClass().getResource("/defender/stone.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        ston = new JButton((Icon) img);
        ston.setToolTipText("<html>" + stone.popup() + "</html>");
        ston.setSize(40, 40);
        ston.setLocation(360, 10);
        ston.addActionListener(this);
        row4.add(ston);
        
        sto = new JLabel();
        sto.setText(stone.getlv() + "/" + stone.getmax());
        sto.setSize(20,20);
        sto.setLocation(400, 30);
        row4.add(sto);
        
      //row5
        row5 = new JPanel();
        row5.setLayout(null);
        row5.setLocation(0, 240);
        row5.setSize(430, 60);
        row5.setBackground(Color.lightGray);
        row5.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
        skills.add(row5);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 58,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row3arr = new JLabel((Icon) img);
        row3arr.setSize(20,58);
        row3arr.setLocation(20, 1);
        row5.add(row3arr);
        
      //Shield Slam
        img = new ImageIcon(getClass().getResource("/defender/shield.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        shiel = new JButton((Icon) img);
        shiel.setToolTipText("<html>" + shield.popup() + "</html>");
        shiel.setSize(40, 40);
        shiel.setLocation(80, 10);
        shiel.addActionListener(this);
        row5.add(shiel);
        
        shie = new JLabel();
        shie.setText(shield.getlv() + "/" + shield.getmax());
        shie.setSize(20,20);
        shie.setLocation(120, 30);
        row5.add(shie);
        
      //Steel Wall
        img = new ImageIcon(getClass().getResource("/defender/steel.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        stee = new JButton((Icon) img);
        stee.setToolTipText("<html>" + steel.popup() + "</html>");
        stee.setSize(40, 40);
        stee.setLocation(220, 10);
        stee.addActionListener(this);
        row5.add(stee);
        
        ste = new JLabel();
        ste.setText(steel.getlv() + "/" + steel.getmax());
        ste.setSize(20,20);
        ste.setLocation(260, 30);
        row5.add(ste);
        
        //Encouraging shout
        img = new ImageIcon(getClass().getResource("/defender/eshout.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        eshou = new JButton((Icon) img);
        eshou.setToolTipText("<html>" + eshout.popup() + "</html>");
        eshou.setSize(40, 40);
        eshou.setLocation(290, 10);
        eshou.addActionListener(this);
        row5.add(eshou);
        
        esho = new JLabel();
        esho.setText(eshout.getlv() + "/" + eshout.getmax());
        esho.setSize(20,20);
        esho.setLocation(330, 30);
        row5.add(esho);
        
      //Resiliance
        img = new ImageIcon(getClass().getResource("/defender/resiliance.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        resil = new JButton((Icon) img);
        resil.setToolTipText("<html>" + resiliance.popup() + "</html>");
        resil.setSize(40, 40);
        resil.setLocation(360, 10);
        resil.addActionListener(this);
        row5.add(resil);
        
        resi = new JLabel();
        resi.setText(resiliance.getlv() + "/" + resiliance.getmax());
        resi.setSize(20,20);
        resi.setLocation(400, 30);
        row5.add(resi);
        
        img = new ImageIcon(getClass().getResource("/defender/downarrow.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(20, 20,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        row34arr = new JLabel((Icon) img);
        row34arr.setSize(20,20);
        row34arr.setLocation(300, 290);
        skills.add(row34arr,0);
        
      //row6
        row6 = new JPanel();
        row6.setLayout(null);
        row6.setLocation(0, 300);
        row6.setSize(430, 60);
        row6.setBackground(Color.lightGray);
        row6.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
        skills.add(row6);
        
      //Cyclone Strike
        img = new ImageIcon(getClass().getResource("/defender/gale.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        gal = new JButton((Icon) img);
        gal.setToolTipText("<html>" + gale.popup() + "</html>");
        gal.setSize(40, 40);
        gal.setLocation(10, 10);
        gal.addActionListener(this);
        row6.add(gal);
        
        ga = new JLabel();
        ga.setText(gale.getlv() + "/" + gale.getmax());
        ga.setSize(20,20);
        ga.setLocation(50, 30);
        row6.add(ga);
        
      //Evasive Strike
        img = new ImageIcon(getClass().getResource("/defender/evastrike.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        evas = new JButton((Icon) img);
        evas.setToolTipText("<html>" + evastrike.popup() + "</html>");
        evas.setSize(40, 40);
        evas.setLocation(150, 10);
        evas.addActionListener(this);
        row6.add(evas);
        
        eva = new JLabel();
        eva.setText(evastrike.getlv() + "/" + evastrike.getmax());
        eva.setSize(20,20);
        eva.setLocation(190, 30);
        row6.add(eva);
        
      //Vigilance
        img = new ImageIcon(getClass().getResource("/defender/vigilance.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        vigil = new JButton((Icon) img);
        vigil.setToolTipText("<html>" + vigilance.popup() + "</html>");
        vigil.setSize(40, 40);
        vigil.setLocation(220, 10);
        vigil.addActionListener(this);
        row6.add(vigil);
        
        vigi = new JLabel();
        vigi.setText(vigilance.getlv() + "/" + vigilance.getmax());
        vigi.setSize(20,20);
        vigi.setLocation(260, 30);
        row6.add(vigi);
        
      //Defensive Shout
        img = new ImageIcon(getClass().getResource("/defender/dshout.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        dshou = new JButton((Icon) img);
        dshou.setToolTipText("<html>" + dshout.popup() + "</html>");
        dshou.setSize(40, 40);
        dshou.setLocation(290, 10);
        dshou.addActionListener(this);
        row6.add(dshou);
        
        dsho = new JLabel();
        dsho.setText(dshout.getlv() + "/" + dshout.getmax());
        dsho.setSize(20,20);
        dsho.setLocation(330, 30);
        row6.add(dsho);
        
      //row7
        row7 = new JPanel();
        row7.setLayout(null);
        row7.setLocation(0, 360);
        row7.setSize(430, 60);
        row7.setBackground(Color.lightGray);
        row7.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK));
        skills.add(row7);
        
      //Threaten
        img = new ImageIcon(getClass().getResource("/defender/threaten.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        threate = new JButton((Icon) img);
        threate.setToolTipText("<html>" + threaten.popup() + "</html>");
        threate.setSize(40, 40);
        threate.setLocation(290, 10);
        threate.addActionListener(this);
        row7.add(threate);
        
        threat = new JLabel();
        threat.setText(threaten.getlv() + "/" + threaten.getmax());
        threat.setSize(20,20);
        threat.setLocation(330, 30);
        row7.add(threat);
        
      //Retribution
        img = new ImageIcon(getClass().getResource("/defender/retribution.png"));
        test = img.getImage();
        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
        img = new ImageIcon(newimg);
        retr = new JButton((Icon) img);
        retr.setToolTipText("<html>" + retribution.popup() + "</html>");
        retr.setSize(40, 40);
        retr.setLocation(360, 10);
        retr.addActionListener(this);
        row7.add(retr);
        
        ret = new JLabel();
        ret.setText(retribution.getlv() + "/" + retribution.getmax());
        ret.setSize(20,20);
        ret.setLocation(400, 30);
        row7.add(ret);
        
        
        
        
        
        
        allpanels.setOpaque(true);
        return allpanels;
		
		
	}
	
	public void updatedef() {
		int allpoints = (deftreepoints+Sintree.getsinpoints()+Clertree.getclerpoints()+Sorctree.getsorcpoints()+Zerktree.getzerkpoints());
		info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
		sin.setText("Assassin(" + Sintree.getsinpoints() + ")");
		cleric.setText("Cleric(" + Clertree.getclerpoints() + ")");
		sorc.setText("Sorcerer(" + Sorctree.getsorcpoints() + ")");
		zerk.setText("Berserker(" + Zerktree.getzerkpoints() + ")");
	}
	
	public void recentset() {
		recentreset = true;
	}
	
	public void actionPerformed(ActionEvent e) {
		int allpoints = (deftreepoints+Sintree.getsinpoints()+Clertree.getclerpoints()+Sorctree.getsorcpoints()+Zerktree.getzerkpoints());
		
		if(e.getSource() == reset) {
			deftreepoints = 0;
			//frame.setContentPane(demo.createContentPane());
	        //frame.setVisible(true);
	        Alltrees.resetdef();
			
        }
		if(e.getSource() == sin) {
			//deftreepoints = 0;
			//frame.setContentPane(demo.createContentPane());
	        //frame.setVisible(true);
			recentreset = false;
	        Alltrees.switchsin();
        } else if(e.getSource() == resetall) {
			//sintreepoints = 0;
			//frame.setContentPane(demo.createContentPane());
	        //frame.setVisible(true);
	        Alltrees.resetall(); 
			
        }else if(e.getSource() == cleric) {
			//sintreepoints = 0;
			//frame.setContentPane(demo.createContentPane());
	        //frame.setVisible(true);
        	recentreset = false;
	        Alltrees.switchcler(); 
			
        }else if(e.getSource() == sorc) {
			//sintreepoints = 0;
			//frame.setContentPane(demo.createContentPane());
	        //frame.setVisible(true);
        	recentreset = false;
	        Alltrees.switchsorc(); 
			
        }else if(e.getSource() == zerk) {
			//sintreepoints = 0;
			//frame.setContentPane(demo.createContentPane());
	        //frame.setVisible(true);
        	recentreset = false;
	        Alltrees.switchzerk(); 
			
        }
		//row 1
		else if ((Sintree.getsinpoints() == 0 && Clertree.getclerpoints() == 0 && Sorctree.getsorcpoints() == 0 && Zerktree.getzerkpoints() == 0) || Sintree.getsinpoints() >= 10 || Clertree.getclerpoints() >= 10 ||
				deftreepoints >= 10 || Sorctree.getsorcpoints() >= 10 || recentreset || Zerktree.getzerkpoints() >= 10) {
			if(e.getSource() == sor) {
			if (ruin.getlv() < ruin.getmax() && ruin.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				ruin.setcurlv(ruin.getlv()+1);
				sor.setToolTipText("<html>" + ruin.popup() + "</html>");
				rui.setText(ruin.getlv() + "/" + ruin.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == stunn) {
			if (stunning.getlv() < stunning.getmax() && stunning.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				stunning.setcurlv(stunning.getlv()+1);
				stunn.setToolTipText("<html>" + stunning.popup() + "</html>");
				stun.setText(stunning.getlv() + "/" + stunning.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == rus) {
			if (rush.getlv() < rush.getmax() && rush.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				rush.setcurlv(rush.getlv()+1);
				rus.setToolTipText("<html>" + rush.popup() + "</html>");
				rushh.setText(rush.getlv() + "/" + rush.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == thor) {
			if (thorn.getlv() < thorn.getmax() && thorn.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				thorn.setcurlv(thorn.getlv()+1);
				thor.setToolTipText("<html>" + thorn.popup() + "</html>");
				tho.setText(thorn.getlv() + "/" + thorn.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == onem) {
			if (onemastery.getlv() < onemastery.getmax() && onemastery.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				onemastery.setcurlv(onemastery.getlv()+1);
				onem.setToolTipText("<html>" + onemastery.popup() + "</html>");
				one.setText(onemastery.getlv() + "/" + onemastery.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } //row2
        else if(e.getSource() == slamm) {
			if (slam.getlv() < slam.getmax() && slam.getpoints() <= deftreepoints && totalpoints > allpoints && rush.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				slam.setcurlv(slam.getlv()+1);
				slamm.setToolTipText("<html>" + slam.popup() + "</html>");
				sla.setText(slam.getlv() + "/" + slam.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == comeb) {
			if (comeback.getlv() < comeback.getmax() && comeback.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				comeback.setcurlv(comeback.getlv()+1);
				comeb.setToolTipText("<html>" + comeback.popup() + "</html>");
				come.setText(comeback.getlv() + "/" + comeback.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } //row3
        else if(e.getSource() == pierce) {
			if (piercing.getlv() < piercing.getmax() && piercing.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				piercing.setcurlv(piercing.getlv()+1);
				pierce.setToolTipText("<html>" + piercing.popup() + "</html>");
				pierc.setText(piercing.getlv() + "/" + piercing.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == rapi) {
			if (rapid.getlv() < rapid.getmax() && rapid.getpoints() <= deftreepoints && totalpoints > allpoints && stunning.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				rapid.setcurlv(rapid.getlv()+1);
				rapi.setToolTipText("<html>" + rapid.popup() + "</html>");
				rap.setText(rapid.getlv() + "/" + rapid.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == fshou) {
			if (fshout.getlv() < fshout.getmax() && fshout.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				fshout.setcurlv(fshout.getlv()+1);
				fshou.setToolTipText("<html>" + fshout.popup() + "</html>");
				fsho.setText(fshout.getlv() + "/" + fshout.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == defma) {
			if (defmastery.getlv() < defmastery.getmax() && defmastery.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				defmastery.setcurlv(defmastery.getlv()+1);
				defma.setToolTipText("<html>" + defmastery.popup() + "</html>");
				defm.setText(defmastery.getlv() + "/" + defmastery.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } //row4
        else if(e.getSource() == chaot) {
			if (chaotic.getlv() < chaotic.getmax() && chaotic.getpoints() <= deftreepoints && totalpoints > allpoints && piercing.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				chaotic.setcurlv(chaotic.getlv()+1);
				chaot.setToolTipText("<html>" + chaotic.popup() + "</html>");
				chao.setText(chaotic.getlv() + "/" + chaotic.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == massiv) {
			if (massive.getlv() < massive.getmax() && massive.getpoints() <= deftreepoints && totalpoints > allpoints && slam.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				massive.setcurlv(massive.getlv()+1);
				massiv.setToolTipText("<html>" + massive.popup() + "</html>");
				massi.setText(massive.getlv() + "/" + massive.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == basti) {
			if (bastion.getlv() < bastion.getmax() && bastion.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				bastion.setcurlv(bastion.getlv()+1);
				basti.setToolTipText("<html>" + bastion.popup() + "</html>");
				bast.setText(bastion.getlv() + "/" + bastion.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == ston) {
			if (stone.getlv() < stone.getmax() && stone.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				stone.setcurlv(stone.getlv()+1);
				ston.setToolTipText("<html>" + stone.popup() + "</html>");
				sto.setText(stone.getlv() + "/" + stone.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } //row5
        else if(e.getSource() == shiel) {
			if (shield.getlv() < shield.getmax() && shield.getpoints() <= deftreepoints && totalpoints > allpoints && rapid.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				shield.setcurlv(shield.getlv()+1);
				shiel.setToolTipText("<html>" + shield.popup() + "</html>");
				shie.setText(shield.getlv() + "/" + shield.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == stee) {
			if (steel.getlv() < steel.getmax() && steel.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				steel.setcurlv(steel.getlv()+1);
				stee.setToolTipText("<html>" + steel.popup() + "</html>");
				ste.setText(steel.getlv() + "/" + steel.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == eshou) {
			if (eshout.getlv() < eshout.getmax() && eshout.getpoints() <= deftreepoints && totalpoints > allpoints && fshout.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				eshout.setcurlv(eshout.getlv()+1);
				eshou.setToolTipText("<html>" + eshout.popup() + "</html>");
				esho.setText(eshout.getlv() + "/" + eshout.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == resil) {
			if (resiliance.getlv() < resiliance.getmax() && resiliance.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				resiliance.setcurlv(resiliance.getlv()+1);
				resil.setToolTipText("<html>" + resiliance.popup() + "</html>");
				resi.setText(resiliance.getlv() + "/" + resiliance.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } //row6
        else if(e.getSource() == gal) {
			if (gale.getlv() < gale.getmax() && gale.getpoints() <= deftreepoints && totalpoints > allpoints && chaotic.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				gale.setcurlv(gale.getlv()+1);
				gal.setToolTipText("<html>" + gale.popup() + "</html>");
				ga.setText(gale.getlv() + "/" + gale.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == evas) {
			if (evastrike.getlv() < evastrike.getmax() && evastrike.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				evastrike.setcurlv(evastrike.getlv()+1);
				evas.setToolTipText("<html>" + evastrike.popup() + "</html>");
				eva.setText(evastrike.getlv() + "/" + evastrike.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == vigil) {
			if (vigilance.getlv() < vigilance.getmax() && vigilance.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				vigilance.setcurlv(vigilance.getlv()+1);
				vigil.setToolTipText("<html>" + vigilance.popup() + "</html>");
				vigi.setText(vigilance.getlv() + "/" + vigilance.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == dshou) {
			if (dshout.getlv() < dshout.getmax() && dshout.getpoints() <= deftreepoints && totalpoints > allpoints && eshout.getlv() > 0) {
				deftreepoints ++;
				allpoints ++;
				dshout.setcurlv(dshout.getlv()+1);
				dshou.setToolTipText("<html>" + dshout.popup() + "</html>");
				dsho.setText(dshout.getlv() + "/" + dshout.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } //row7
        else if(e.getSource() == threate) {
			if (threaten.getlv() < threaten.getmax() && threaten.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				threaten.setcurlv(threaten.getlv()+1);
				threate.setToolTipText("<html>" + threaten.popup() + "</html>");
				threat.setText(threaten.getlv() + "/" + threaten.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        } else if(e.getSource() == retr) {
			if (retribution.getlv() < retribution.getmax() && retribution.getpoints() <= deftreepoints && totalpoints > allpoints) {
				deftreepoints ++;
				allpoints ++;
				retribution.setcurlv(retribution.getlv()+1);
				retr.setToolTipText("<html>" + retribution.popup() + "</html>");
				ret.setText(retribution.getlv() + "/" + retribution.getmax());
				info.setText("<html>Points Used: " + allpoints + "<br>Points Left: " + (totalpoints-allpoints) + "</html>");
			} 
        }
		}
		if (deftreepoints == 5) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/counterattack.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        counter.setIcon((Icon) img);
	        img = new ImageIcon(getClass().getResource("/defender/chainmastery.png"));
	        test = img.getImage();
	        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
			chain.setIcon((Icon) img);
		}
		if (deftreepoints == 10) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/stylemastery.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        cross.setIcon((Icon) img);
	        recentreset = false;
		}
		if (deftreepoints == 15) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/platemastery.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        plate.setIcon((Icon) img);
	        img = new ImageIcon(getClass().getResource("/defender/phytraining.png"));
	        test = img.getImage();
	        newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
			phy1.setIcon((Icon) img);
		}
		if (deftreepoints == 20) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/extendcounter.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        exe1.setIcon((Icon) img);
		} 
		if (deftreepoints == 25) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/phytraining.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        phy2.setIcon((Icon) img);
		}
		if (deftreepoints == 30) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/extendcounter.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        exe2.setIcon((Icon) img);
		} 
		if (deftreepoints == 35) {
			ImageIcon img = new ImageIcon(getClass().getResource("/defender/phytraining.png"));
	        Image test = img.getImage();
	        Image newimg = test.getScaledInstance(40, 40,  java.awt.Image.SCALE_SMOOTH);
	        img = new ImageIcon(newimg);
	        phy3.setIcon((Icon) img);
		}
		allpoints = (deftreepoints+Sintree.getsinpoints()+Clertree.getclerpoints()+Sorctree.getsorcpoints()+Zerktree.getzerkpoints());
		if (allpoints == 40) {
			if (deftreepoints < 10 && Sintree.getsinpoints() < 10 && Clertree.getclerpoints() < 10 && Sorctree.getsorcpoints() < 10 && 
					Zerktree.getzerkpoints() < 10) {
				JOptionPane.showMessageDialog (null, "Error: Invalid Tree\nNone of the class trees has at least 10 points\n" +
						"Reseting",
		        			"Invalid", JOptionPane.ERROR_MESSAGE);
				Alltrees.resetall();
			}
		}
		def.setText("Defender(" + deftreepoints + ")");
		
	}
	
	
	
	

	

}

